package com.example.core.utils

import android.annotation.SuppressLint
import android.content.Context
import android.content.SharedPreferences
import com.example.core.BaseApplication
import com.example.core.R

object CacheUtils  {


//    @SuppressLint("StaticFieldLeak")
    //kotlin中访问currentApplication
//    private  var  context: Context = BaseApplication.currentApplication()
    private  var  context: Context = BaseApplication.currentApplication//优化去掉方法现在是直接访问成员

    private   var SP: SharedPreferences = context.getSharedPreferences(context.getString(R.string.app_name), Context.MODE_PRIVATE);


    //简化函数声明
       fun save( key:String,   value:String) = SP.edit().putString(key, value).apply()

    //简化函数
        fun get( key:String?) = SP.getString(key, null);



}